"use strict";
/* Controllers  dataMetricDapanListController*/
app.controller("delServiceController", ['$scope', '$location', '$rootScope', '$routeParams','dataDelService', function ($scope, $location, $rootScope, $routeParams,dataDelService) {

    var vm = $scope.vm = {};
    vm.p = {};
    vm.result = {};
    vm.items=[];

    var errorFn = function (result) {
        alert(result);
    };

    $scope.delMetricSource = function () {
        var vm = $scope.vm;
        var params = {id:$routeParams.id};
        var procFn = function (response) {
            vm.result.ms = response.ms;
            if ("000" !== response.code) {
                alert(response.message);
                return ;
            }

            if (response.success && response.data) {
                alert("删除成功！")
            } else {
                alert(response.msg);
            }
            vm.result.ms = response.ms;
            var data = response.data;
            if (data == null) return;
            vm.result.data = data;
        };
        dataDelService.delElement(params, procFn, errorFn);
    };



    $scope.initializeController = function () {
        $scope.delMetricSource();
    };
    $scope.initializeController();

}]);


/* Services */
app.service('dataDelService', ['ajaxService', function (ajaxService) {

    this.delElement = function (params, successFunction, errorFunction) {
        ajaxService.AjaxPost(params, "/star/api/basic-service/v1/data_content/delMetricSource.do", successFunction, errorFunction);
    };

}]);
